<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<select id="db">
			<option value ="">请选择大小</option>
			<option value ="大">大</option>
			<option value ="小">小</option>
		</select>
		<div id="" style="width: 200px; height: 120px;">
			<img id="id2" src="img/摇色子/1.jpg" >
		</div>
		<button type="button" onclick="doaction();">开始</button>
	</body>
	<script type="text/javascript">
		function doaction(){
			var dd =document.getElementById('db');
			if (dd.value =='') {
				alert('请选择');
				location.reload();
			}
			var img = document.getElementById('id2');
			var bb =0;
			var cc= setInterval(function(){
				var num =Math.floor(Math.random()*6+1);
				img.src ='img/摇色子/'+num+'.jpg';
				console.log(num);
				bb++;
				if (bb >= 10) {
					clearInterval(cc);
					setTimeout(function(){
					if (dd.value =='大') {
						if (num>3) {
							alert('答对了')
						} else{
							alert('答错了')
						}
					}
					if (dd.value =='小') {
						if (num<4) {
							alert('答对了')
						} else{
							alert('答错了')
						}
					}},500)
					
				}
			},500);
		}
	</script>
</html>
